package com.daiyang.testdemo.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@Controller
@RequestMapping("/Data")
public class RespondControler {
    @ResponseBody
    @RequestMapping("/returnData1")
    public String RespondControler1() {
        return "数据";
    }
    @ResponseBody
    @RequestMapping("/returnData2")
    public String RespondControler2() {
        return "<h1>Hello,HTML~</h1>";
    }
    @RequestMapping("/returnData3")
    public String RespondControler3() {
        return "/test.html";
    }
    @ResponseBody
    @RequestMapping("/returnData4")
    public HashMap<String, String>RespondControler4() {
        HashMap<String, String> map = new HashMap<>();
        map.put("Java", "Java Value");
        map.put("MySQL", "MySQL Value");
        map.put("Redis", "Redis Value");
        return map;
    }
    @ResponseBody
    @RequestMapping("/returnData5")
    public String RespondControler5(HttpServletResponse response) {
        response.setStatus(999);
        return "设置成功";
    }
    @RequestMapping(value = "/returnJson2")
    @ResponseBody
    public String returnJson2() {
        return "{\"success\":true}";
    }
    @ResponseBody
    @RequestMapping("/returnData6")
    public String RespondControler6(HttpServletResponse response, HttpServletRequest request) {
        response.setHeader("111", "111");
        return "设置成功";
    }
}
